package com.cruise.h5.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cruise.common.web.result.Result;
import com.cruise.h5.pojo.dto.LikeDTO;
import com.cruise.h5.pojo.dto.PostDTO;
import com.cruise.h5.pojo.dto.PostListDTO;
import com.cruise.h5.pojo.vo.PostListVO;
import com.cruise.h5.service.PostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cruise
 * @since 2021-03-25
 */
@Api(tags = "动态接口")
@RestController
@RequestMapping("/h5/post")
public class PostController {

    @Resource
    private PostService postService;

    /**
     * 如果发表的是 图片，最多9张，如果是视频，只有1个视频
//     * @param postDTO
     * @return
     */
    @ApiOperation("发布动态")
    @PostMapping("/post")
    public Result post(@RequestBody PostDTO postDTO){
        System.out.println(postDTO);
        postService.post(postDTO);
        return Result.success();
    }


    @ApiOperation("点赞动态/取消点赞动态")
    @PostMapping("/like")
    public Result like(@RequestBody LikeDTO likeDTO){
        postService.like(likeDTO);
        return Result.success();
    }

    @ApiOperation("post列表")
    @PostMapping("/postList")
    public Result<IPage<PostListVO>> postList(@RequestBody PostListDTO postListDTO){
        Result<IPage<PostListVO>> postListVoResult = postService.postList(postListDTO);
        return postListVoResult;
    }


}

